package com.gzhxhx.czh.myhuibaomin.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.gzhxhx.czh.myhuibaomin.R;
import com.gzhxhx.czh.myhuibaomin.httpgetset.ShoyeListUtils;
import com.squareup.picasso.Picasso;

import java.util.List;

public class ShoyelistAdapter extends BaseAdapter {
    Context context;
    List<ShoyeListUtils.DataBean> list;

    public ShoyelistAdapter(Context context,List<ShoyeListUtils.DataBean> list){
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TeView teView;
        if (convertView==null){
            teView = new TeView();
            convertView = View.inflate(context, R.layout.itme_list_shoye_list,null);
            teView.imgTp = convertView.findViewById(R.id.img_shoye_list_tp);
            teView.tvDz = convertView.findViewById(R.id.tv_shoye_list_dz);
            teView.tvGs = convertView.findViewById(R.id.tv_shoye_list_gs);
            teView.tvJg = convertView.findViewById(R.id.tv_shoye_list_jg);
            teView.tvWz = convertView.findViewById(R.id.tv_shoye_list_wz);
            teView.tvXl = convertView.findViewById(R.id.tv_shoye_list_xl);
            convertView.setTag(teView);
        }else {
            teView = (TeView) convertView.getTag();
        }
        teView.tvXl.setText("已卖出："+list.get(position).getXiaolian());
        teView.tvWz.setText(list.get(position).getWenzhi());
        teView.tvJg.setText(list.get(position).getJiage());
        teView.tvGs.setText(list.get(position).getGuishu());
        teView.tvDz.setText(list.get(position).getDizhi());
        Picasso.with(context)
                .load(list.get(position).getImgurl())
                .error(R.drawable.logo)
                .into( teView.imgTp);
        return convertView;
    }

    class TeView{
        ImageView imgTp;
        TextView tvJg,tvXl,tvDz,tvGs,tvWz;


    }
}
